class Animal:
    a_type = '哺乳动物'

    def __init__(self, name, age, sex):
        self.name = name
        self.age = age
        self.sex = sex

    def eat(self):
        print("%s is eating..." % self.name)


class Person(Animal):
    a_type = '高级哺乳动物'

    def __init__(self, name, age, sex, hobbie):
        # Animal.__init__(self, name, age, sex) # 执行父类构造方式 python2
        # super(Person, self).__init__(name, age, sex)  # 调用父类的构造方法 python3
        super().__init__(name, age, sex) # python3,一般用得比较多
        self.hobbie = hobbie

    def talk(self):
        print('person %s is talking...' % self.name)

    def eat(self):
        Animal.eat(self)
        print('%s在优雅地吃...' % self.name)

    def print_hobbie(self):
        print('爱好是%s' % self.hobbie)


class Dog(Animal):
    def bark(self):
        print('dog %s is barking...' % self.name)


p = Person('Alex', 22, 'M', '读书')
p.eat()
p.talk()
p.print_hobbie()
print(p.a_type)

d = Dog('Mjj', 3, 'F')
d.eat()
d.bark()
print(d.a_type)